package com.caojing.syby.ui.search;

import android.content.Intent;
import android.view.View;
import android.widget.AdapterView;
import android.widget.GridView;
import android.widget.TextView;

import com.caojing.syby.R;
import com.caojing.syby.base.BaseActivity;
import com.caojing.syby.bean.search.ClasslyBean;
import com.caojing.syby.ui.adapter.ShowAdapter;
import com.caojing.syby.ui.details.searchdetails.SearchDetailActivity;

import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;
import butterknife.OnClick;

public class SearchActivity extends BaseActivity {


    @Bind(R.id.search_activity_tvSearch)
    TextView searchActivityTvSearch;
    @Bind(R.id.search_activity_gv)
    GridView searchActivityGv;
    private List<ClasslyBean> list=new ArrayList<>();
    private String[] name;
    @Override
    protected int getLayoutId() {
        return R.layout.activity_search;
    }

    @Override
    protected void initView() {
        int[]classify={R.mipmap.fushi,R.mipmap.nanzhuang,
                R.mipmap.jujia,R.mipmap.muying,
                R.mipmap.xiebao,R.mipmap.neiyi,
                R.mipmap.meishi,R.mipmap.shuma,
                R.mipmap.huazhuangpin,R.mipmap.wenti,
                R.mipmap.oldman,R.mipmap.peishi,
                R.mipmap.jkj,R.mipmap.newsort,
                R.mipmap.all};
        name= new String[]{"女装", "男装", "居家", "母婴", "鞋包", "内衣",
                "美食", "数码家电", "美妆个护", "文体", "中老年", "配饰", "十元包邮",
                "今日更新", "全部"};
        for (int i = 0; i <classify.length ; i++) {
            ClasslyBean classlyBean=new ClasslyBean(name[i],classify[i]);
            list.add(classlyBean);
        }
    }

    @Override
    protected void initData() {
        ShowAdapter adapter=new ShowAdapter(list);
        searchActivityGv.setAdapter(adapter);
        searchActivityGv.setOnItemClickListener(    new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
                Intent intent = new Intent(SearchActivity.this, SearchDetailActivity.class);
                intent.putExtra("sort",position);
                intent.putExtra("name",name[position]);
                startActivity(intent);
            }
        });
    }

    @OnClick(R.id.search_activity_tvSearch)
    public void onClick() {
    }
}
